package 笔试.米哈游;

import org.junit.Test;

import java.util.Collections;
import java.util.PriorityQueue;

public class one {
    @Test
    public void test() {
        int[] p={3,2,1,5,6,4};
        System.out.println(findKthLargest(p,2));
    }

    public int findKthLargest (int[] nums, int k) {
        PriorityQueue<Integer> q = new PriorityQueue<>(Collections.reverseOrder());
        int res = nums[0];
        for (int num : nums) {
            q.add(num);
        }

        for (int i = 0; i < k; i++) {
            res = q.poll();
        }
        return res;
    }
}
